import logging
import time

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By

from yizuauto.common.dologs import DoLog

dolog = DoLog().set_get_logger(logging.INFO)
class RegPage():
    unameE = (By.NAME, "username")
    uemailE = (By.NAME, "email")
    upwdE = (By.NAME, "password")
    upwdE2 = (By.NAME, "confirm_password")
    utep = (By.NAME, "extend_field5")
    regE = (By.NAME, "Submit")
    # a = DoLog().set_get_logger(logging.INFO)

    # l=['张丽丽','1234352@qq.com','1234561','1234561','12354678']
    # wd.find_element(By.XPATH,"/html/body/div[3]/div[3]/div[1]/div[1]/ul/li[2]/a ").click()
    def zhuce(self, wd,a, b, c, d, e):

        wd.get("http://192.168.88.100/user.php?act=register")
        wd.implicitly_wait(10)

        try:
            wd.find_element(*self.unameE).send_keys(a)
            wd.find_element(*self.uemailE).send_keys(b)
            wd.find_element(*self.upwdE).send_keys(c)
            wd.find_element(*self.upwdE2).send_keys(d)
            wd.find_element(*self.utep).send_keys(e)
            wd.find_element(*self.regE).click()
            time.sleep(3)
        except Exception as e:
            dolog.error("注册失败！！！")
        else:
            dolog.info("注册成功！！！")
        finally:
            dolog.info("注册结束了！！！")

    # def dizhi(self, wd, param, param1, param2, param3, param4):
    #     pass


if __name__ == '__main__':
    wd = webdriver.WebDriver()
    rp = RegPage()
    rp.zhuce(wd,'wu15', '24111785@qq.com', '123456', '123456', '12345178900')
